<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // ES6没有引入class之前的定义一个类写法

    // function Person(name){
    //     this.name = name;
    // }
    // Person.prototype.hello = function (){
    //     alert("hello")
    // }
    // Person.prototype.hello()

    //ES6引入class之后定义一个类、属性、方法
    class Person{
        //有参构造
        constructor(name) {
            this.name = name;
            alert("My Name Is : " + name);
        }
        hello(){
            alert("hello")
        }
    }
    let xm = new Person("小明");
    xm.name;
    xm.hello();

    class BigPerson extends Person{
        constructor(typeName) {
            super(typeName);
            this.typeName = typeName;
        }
        whoIsMe(){
            alert("我是一个"+this.typeName);
        }
    }
    let xh = new BigPerson("大人");
    xh.typeName;
    xh.whoIsMe();
    xh.hello();
</script>
</body>
</html>